package com.ror.java.se.map.hashmap;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo02HashMapK2V {
    public static void main(String[] args) {
        Map<String, String> map = new HashMap<>();
        map.put("12dora", "9bishi");
        map.put("api", "xrb");
        map.put("lbb", "bls");

        //键找值遍历
        Set<String> keys = map.keySet();
        for (String key : keys) {
            String val = map.get(key);
            System.out.println(key + "=" + val);
        }

        System.out.println("===================");

        //键值对遍历
        for (Map.Entry<String, String> entry : map.entrySet()) {
//            System.out.println(entry.getKey() + "=" + entry.getValue());
            System.out.println(entry);
        }

        System.out.println("===================");

        //lambda遍历
        map.forEach((key,val) -> {
            System.out.println(key + "=" + val);
        });
    }
}
